/**
 * 
 */
var eduorg_frame = eduorg_frame||{};

/**
 * 删除树上指定id的节点
 */
eduorg_frame.deleteNodeById = function(treeNodeId){
	var zTree = $.fn.zTree.getZTreeObj("schooltree");
	var nodes = zTree.getNodesByParam("id", treeNodeId, null);
	zTree.removeNode(nodes[0]);
}
eduorg_frame.freshTree = function(){
	var zTree = $.fn.zTree.getZTreeObj("schooltree");
	var nodes = treeObj.getNodes();
	if (zTree.length>0) {
		 zTree.expandNode(nodes[0]);
	}


}
/**
 * 目录树
 */
var chnRootNode=[
                 {code:100000, id:1, name:"行政组织机构", isParent:true, type:0}
     ];
 var setting = {
			view: {
	        	showTitle: false,
		        dblClickExpand: false,
		        showLine: false,
		        fontCss: setFontCss
		     },
			async : {
				enable : true,
				url : getUrl
			},
			callback : {
				onClick : zTreeNodeOnClick
				//onAsyncSuccess: zTreeOnAsyncSuccess

			}
		};
 function getUrl(treeId,treeNode){
	   if(treeNode.type==0){
		  return "manage/eduorg_orgListData.action?parentId="+treeNode.id+"&rdm="+Math.random();
	 }else{
		  return "manage/eduorg_departListData.action?parentId="+treeNode.id+"&rdm="+Math.random();
	 }
 };
 /**
  * 单击节点
  * @param event
  * @param treeId
  * @param treeNode
  */
function zTreeNodeOnClick(event, treeId, treeNode) {//响应节点点击事件
	var zTree = $.fn.zTree.getZTreeObj("schooltree");
	 zTree.expandNode(treeNode);//展开节点
	 var listFrame = window.parent.document.getElementById("list_iframe");
	 var nodeType = treeNode.type;
	 listFrame.src="manage/sysUser_list.action?orgId="+treeNode.id+"&nodeType="+nodeType+"&rdm="+Math.random();

 };
 
 function setFontCss(treeId, treeNode){
	 if(treeNode.type==1){
		return {color:"red"}
	 }
	 if(treeNode.type==2){
		return {color:"blue"}
	 }
 }
 /**
  * 初始化 加载Tree
  */
 $(document).ready(function(){
	   zTreeInit("schooltree" ,true,true,null,null,1);
//	   zTreeInit("schooltree" ,true,true,null,null,3);
 });